package com.chat.datea.acitivity;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.chat.datea.R;
import com.chat.datea.utils.reflection.ReflectionUtil;

/**
 * Created by Shura on 15/11/7.
 */
public class ChangeSkinActivity extends Activity implements View.OnClickListener{

    private ImageView change_skin_back;
    private ImageView skin_blue, skin_red, skin_green, skin_gold, skin_cyan, skin_grey;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_skin);

        change_skin_back = (ImageView) findViewById(R.id.change_skin_back);
        skin_blue = (ImageView) findViewById(R.id.skin_blue);
        skin_red = (ImageView) findViewById(R.id.skin_red);
        skin_cyan = (ImageView) findViewById(R.id.skin_cyan);
        skin_gold = (ImageView) findViewById(R.id.skin_cyan);
        skin_green = (ImageView) findViewById(R.id.skin_green);
        skin_grey = (ImageView) findViewById(R.id.skin_grey);

        change_skin_back.setOnClickListener(this);
        skin_blue.setOnClickListener(this);
        skin_red.setOnClickListener(this);
        skin_cyan.setOnClickListener(this);
        skin_gold.setOnClickListener(this);
        skin_green.setOnClickListener(this);
        skin_grey.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.change_skin_back:
                finish();
                break;
            case R.id.skin_red:
                try {
                    // 获取另一apk的Context实例
                    Context context = ReflectionUtil.getSkinContext(ChangeSkinActivity.this, "com.chat.datea.skindemo");

                    // 获取另一apk中color资源下的colorTitleBar属性
                    int textColor = ReflectionUtil.getIdentifier(ChangeSkinActivity.this, "com.chat.datea.skindemo", "colorTitleBar", "color");
//                    linearLayout.setBackgroundColor(context.getResources().getColor(textColor));
//
//                    linearLayout.setBackgroundColor(ReflectionUtil.color(ChangeSkinActivity.this, "com.chat.datea.skindemo", "colorTitleBar"));
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }
                break;
        }
    }
}
